<template>
  <div class="problem_detail w">
    <h3>题目：{{title}}</h3>
    <h3>题目描述</h3>
    <p class="post_content"  >
      {{content}}</p>
    <br>
    <h3>输入格式</h3>
    <p class="post_content">{{input_format}}</p>
    <br>
    <h3>样例数据</h3>
    <p class="post_content">输入</p>
    <ul class="input_output"  >
      <li v-for="i in inputExample.length">{{inputExample[i - 1]}}</li>
    </ul>
    <p class="post_content">输出</p>
    <ul class="input_output"  >
      <li v-for="i in outputExample.length">{{outputExample[i - 1]}}</li>
    </ul>
    <h3>备注</h3>
    <p class="post_content" >{{content}}</p>
  </div>
</template>

<script>
import axios from "axios";
import qs from "qs";
import { Message } from "element-ui";

export default {
  name: "problem_detail",
  data(){
    return{
          id:1,
          title: '',
          input_format: '' +
              '',
          inputExample:[],
          outputExample:[],
          content:'',
          remark:'',
    }
  },
  mounted() {
    axios({
      method: 'post',
      url: '/question/get_question_detail?id='+this.$route.query.problemIndex.toString(),
          })
      .then(res => {
        //获取数据
        if(res.data.errcode===0)
        {

          this.inputExample=[res.data.inputExample];
          this.id=res.data.id;
          this.title=res.data.title;
          this.outputExample=[res.data.outputExample];
          this.content=res.data.content;
          this.remark=res.data.remark;
          this.input_format=res.data.inputFormat;
          console.log(res.data);
        }
        else if(res.data.errcode===-2)
        {
          Message.error("查询不到题目");
        }
        else if(res.data.errcode===-1)
        {
          Message.error("未知错误");

        }
        else {
          Message.error("未知错误");

        }
/*
        this.$message({
          message:res.data,
          type: 'success'
        });*/
      })
      .catch(function (error) {
        this.$message.error(error);
      })

    this.content='';
/*    this.$message({
      message: this.$route.query.problemIndex,
      type: 'success'
    });*/

  },
  methods:{

    getUrl: function (){
      console.log(this.$route.path);
    },
  }
}
</script>

<style scoped>
@import "../../common/stylus/style.css";
@import "../../assets/css/all.css";
@import "../../assets/css/problem_detail.css";
</style>